package com.accenture.fd.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.accenture.fd.entity.UploadFileForProcessListEntity;

	@Mapper
	public interface ProcessListDao {

		     @Select("SELECT process_id," + 
		     		"process_name," + 
		     		"process_abstract," + 
		     		"kubun," + 
		     		"screen_id," + 
		     		"invoice_id," + 
		     		"sys_interface_id," + 
		     		"collect_process_id," + 
		     		"sys_function_id," + 
		     		"biz_pattern_id," + 
		     		"page_process_pattern," + 
		     		"ayn_process_pattern," + 
		     		"transection," + 
		     		"data_stop_flag," + 
		     		"type_kubun," + 
		     		"type," + 
		     		"comment," + 
		     		"close_flag," + 
		     		"trans_to_page," + 
		     		"batch_type," + 
		     		"ajax_kubun" + 
		     		" FROM TB00013 where process_id = #{processId}")
		     @Results({
		    	 @Result(property = "processId", column = "process_id"),
		    	 @Result(property = "processName", column = "process_name"),
		    	 @Result(property = "processAbstract", column = "process_abstract"),
		    	 @Result(property = "kubun", column = "kubun"),
		    	 @Result(property = "screenId", column = "screen_id"),
		    	 @Result(property = "invoiceId", column = "invoice_id"),
		    	 @Result(property = "sysInterfaceId", column = "sys_interface_id"),
		    	 @Result(property = "collectProcessId", column = "collect_process_id"),
		    	 @Result(property = "sysFunctionId", column = "sys_function_id"),
		    	 @Result(property = "bizPatternId", column = "biz_pattern_id"),
		    	 @Result(property = "pageProcessPattern", column = "page_process_pattern"),
		    	 @Result(property = "aynProcessPattern", column = "ayn_process_pattern"),
		    	 @Result(property = "transection", column = "transection"),
		    	 @Result(property = "dataStopFlag", column = "data_stop_flag"),
		    	 @Result(property = "typeKubun", column = "type_kubun"),
		    	 @Result(property = "type", column = "type"),
		    	 @Result(property = "comment", column = "comment"),
		    	 @Result(property = "closeFlag", column = "close_flag"),
		    	 @Result(property = "transToPage", column = "trans_to_page"),
		    	 @Result(property = "batchType", column = "batch_type"),
		    	 @Result(property = "ajaxKubun", column = "ajax_kubun"),

		     })
		     UploadFileForProcessListEntity findByProcessId(@Param("processId") String process_id);

		     @Insert("insert into TB00013 value (#{item.processId}," + 
		     		"#{item.processName}," + 
		     		"#{item.processAbstract}," + 
		     		"#{item.kubun}," + 
		     		"#{item.screenId}," + 
		     		"#{item.invoiceId}," + 
		     		"#{item.sysInterfaceId}," + 
		     		"#{item.collectProcessId}," + 
		     		"#{item.sysFunctionId}," + 
		     		"#{item.bizPatternId}," + 
		     		"#{item.pageProcessPattern}," + 
		     		"#{item.aynProcessPattern}," + 
		     		"#{item.transection}," + 
		     		"#{item.dataStopFlag}," + 
		     		"#{item.typeKubun}," + 
		     		"#{item.type}," + 
		     		"#{item.comment}," + 
		     		"#{item.closeFlag}," + 
		     		"#{item.transToPage}," + 
		     		"#{item.batchType}," + 
		     		"#{item.ajaxKubun})")
		     void save(@Param("item")UploadFileForProcessListEntity item);
		     
		     @Insert({
		    	 "<script>",
		    	 "insert into TB00013 value ",
		    	 "<foreach collection='processList' item='item' index='index' separator=','>",
		    	 "(#{item.processId}, #{item.processName}, #{item.processAbstract}, #{item.kubun}, #{item.screenId}, #{item.invoiceId}, #{item.sysInterfaceId}, #{item.collectProcessId}, #{item.sysFunctionId}, #{item.bizPatternId}, #{item.pageProcessPattern}, #{item.aynProcessPattern}, #{item.transection}, #{item.dataStopFlag}, #{item.typeKubun}, #{item.type}, #{item.comment}, #{item.closeFlag}, #{item.transToPage}, #{item.batchType}, #{item.ajaxKubun})",
		    	 "</foreach>",
		    	 "</script>"
		    	})
		     void saveAll(@Param(value="processList") List<UploadFileForProcessListEntity> processList);
		 	@Delete("truncate table TB00013")
		    void truncate();
		 	
		    @Select("select \r\n" + 
		     		"  process_id\r\n" + 
		     		"from TB00013")
		     @Results({
		    	 @Result(property = "processid", column = "process_id"),
		     })
		     List<String> getprocessid();
		 	
	}
